<script lang="ts">
import { defineComponent } from "vue";

export default defineComponent({
  props: {
    info: { type: Object, required: true },
  },
});
</script>

<template>
  <view class="task-item">
    <view style="display: flex; align-items: center">
      <view class="task-item-type">{{ info.type_name }}</view>
      <view class="task-item-name">{{ info.name }}</view>
      <view class="task-item-state" v-if="info.is_emergency === 1">急单</view>
    </view>
    <view class="task-item-content">
      <view class="task-item-label">导游要求：</view>
      <view class="task-item-tag">
        <view
          class="task-item-tag2"
          v-for="(i, d) of info.guide_need_arr"
          :key="d"
        >
          {{ i }}
        </view>
      </view>
      <view class="task-item-price">
        <template v-if="info.salary_type === 3">议价</template>
        <template v-else>
          <text class="task-item-price2">￥</text>{{ info.salary }}-{{
            info.max_salary
          }}<text class="task-item-price2" v-if="info.salary_type === 2"
            >/日</text
          >
        </template>
      </view>
    </view>
    <view class="task-item-content">
      <view class="task-item-label">出行日期：</view>
      <view class="task-item-value">
        {{ info.start_date }}-{{ info.end_date }}
      </view>
    </view>
    <view class="task-item-content">
      <view class="task-item-label">接待人数：</view>
      <view class="task-item-value">{{ info.recept_count }}人</view>
      <view class="task-item-label">&emsp;目的地：</view>
      <view class="task-item-value">
        {{ info.end_area_name_arr.join("、") }}
      </view>
    </view>
    <view class="task-item-info">
      <image
        class="task-item-avatar"
        :src="info.travel_agency_logo"
        mode="aspectFill"
      />
      <view style="flex-grow: 1; min-width: 0">
        <view class="task-item-creator">{{ info.travel_agency_name }}</view>
        <view class="task-item-date">{{ info.cdate }}</view>
      </view>
    </view>
    <view class="task-item-btn">
      <image
        class="task-item-btn2"
        src="@/package/square/static/task-list-btn.png"
      />
      <view class="task-item-btn3">抢单</view>
    </view>
    <view class="task-item-count" v-if="info.start_time_arr">
      <view class="task-item-count2">距结束</view>
      <view class="task-item-count3">{{ info.start_time_arr[0] }}</view>
      <view class="task-item-count4">天</view>
      <view class="task-item-count3">{{ info.start_time_arr[1] }}</view>
      <view class="task-item-count4">时</view>
      <view class="task-item-count3">{{ info.start_time_arr[2] }}</view>
      <view class="task-item-count4">分</view>
    </view>
  </view>
</template>

<style lang="scss">
.task-item {
  position: relative;
  padding: 30rpx 20rpx 46rpx;
  border-radius: 20rpx;
  background-color: #ffffff;

  .task-item-type {
    flex-shrink: 0;
    padding: 0 10rpx;
    font-size: 20rpx;
    color: #8e5a1f;
    line-height: 32rpx;
    border-radius: 8rpx;
    background: linear-gradient(45deg, #fdecc7, #fed5b2);
  }

  .task-item-name {
    min-width: 0;
    margin: 0 10rpx;
    font-size: 30rpx;
    color: #333333;
    line-height: 48rpx;
    font-weight: bold;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
  }

  .task-item-state {
    flex-shrink: 0;
    padding: 0 8rpx;
    font-size: 20rpx;
    color: #fd3d3a;
    line-height: 28rpx;
    border-radius: 6rpx;
    border: 2rpx solid;
    background: rgba(253, 65, 61, 0.1);
    border-image: linear-gradient(132deg, #fd3d3a 6%, #fb8b6b 93%) 0.5 0.5;
  }

  .task-item-content {
    display: flex;
    align-items: center;
    margin-bottom: 4rpx;
  }

  .task-item-label {
    flex-shrink: 0;
    font-size: 26rpx;
    color: #666666;
    line-height: 48rpx;
  }

  .task-item-tag {
    display: flex;
    flex-wrap: wrap;
    flex-grow: 1;
    min-width: 0;
    height: 32rpx;
    overflow: hidden;
  }

  .task-item-tag2 {
    padding: 0 10rpx;
    margin-right: 10rpx;
    font-size: 20rpx;
    color: #666666;
    line-height: 32rpx;
    border-radius: 8rpx;
    background-color: #f5f5f5;
  }

  .task-item-price {
    flex-shrink: 0;
    font-size: 36rpx;
    color: #fa6400;
    line-height: 50rpx;
    font-weight: bold;
  }

  .task-item-price2 {
    font-size: 24rpx;
    line-height: 34rpx;
  }

  .task-item-value {
    min-width: 0;
    font-size: 26rpx;
    color: #999999;
    line-height: 48rpx;
  }

  .task-item-info {
    display: flex;
    align-items: center;
    margin-top: 30rpx;
  }

  .task-item-avatar {
    flex-shrink: 0;
    width: 40rpx;
    height: 40rpx;
    margin-right: 14rpx;
    border-radius: 50%;
    border: 2rpx solid #f1f1f1;
  }

  .task-item-creator,
  .task-item-date {
    font-size: 24rpx;
    color: #666666;
    line-height: 34rpx;
  }

  .task-item-date {
    color: #999999;
  }

  .task-item-btn {
    position: absolute;
    right: 30rpx;
    bottom: 78rpx;
  }

  .task-item-btn2 {
    display: block;
    width: 112rpx;
    height: 52rpx;
  }

  .task-item-btn3 {
    position: absolute;
    left: 0;
    top: 0;
    right: 0;
    padding-left: 10rpx;
    font-size: 24rpx;
    color: #ffffff;
    line-height: 50rpx;
    text-align: center;
    font-weight: bold;
  }

  .task-item-count {
    position: absolute;
    right: 20rpx;
    bottom: 30rpx;
    display: flex;
    align-items: center;
  }

  .task-item-count2 {
    margin-right: 4rpx;
    font-size: 24rpx;
    color: #333333;
    line-height: 34rpx;
  }

  .task-item-count3 {
    width: 38rpx;
    margin: 0 6rpx;
    font-size: 24rpx;
    color: #f56b2a;
    line-height: 38rpx;
    text-align: center;
    font-weight: bold;
    border-radius: 4rpx;
    background-color: rgba(199, 65, 27, 0.05);
  }

  .task-item-count4 {
    font-size: 20rpx;
    color: #333333;
    line-height: 28rpx;
  }
}
</style>